using System;
using System.Collections.Generic;
using Framework.Unity;

namespace Framework.Core
{
    public interface IWorkItem
    {
        void InitializeCase(ICaseDetails @case);
        IContainer IntrayContainer { get; set; }
        Type IntrayType { get; }
        object Subject { get; set; }
        ICaseDetails ContextCase { get; }
        bool IsRoot { get; }
        string ActionText { get; set; }

        event EventHandler SubjectUpdated;

        /// <summary>
        /// Names of roles that may run the workitem
        /// </summary>
        IEnumerable<string> RoleRestrictions { get; }
        /// <summary>
        /// Conditions that determine if a workitem is visible as an action
        /// </summary>
        IEnumerable<IRuleBase> AvailabilityConditions { get; }
        /// <summary>
        /// Conditions that determine if a workitem can be run
        /// </summary>
        IEnumerable<IRuleBase> DisplayConditions { get; }
        /// <summary>
        /// Conditions that determine if a warning should be displayed before a workitem is run.
        /// </summary>
        IEnumerable<IRuleBase> DisplayWarnings { get; }
        /// <summary>
        /// Conditions that determine if a workitem is finished
        /// </summary>
        IEnumerable<IRuleBase> CompletionConditions { get; }

        int[] AutoRunTaskIds { get; }
        AutoOpenDocumentInfo[] AutoOpenDocumentReferences { get; }

        void InitializeIntray(IWorkItemUI intray);
        void ProcessIntrayResult(IWorkItemUI intray);

        bool Calculate();
        void ExecutionError();
        void ExecutionSuccess();
        void ExecutionNotFinished();
        CanCompleteResult CanComplete(object intrayData);

        bool ExecuteWorkItem<T>(Action<T> initWorkItem, object subject) where T : IWorkItem;
        bool ExecuteWorkItem(Type workItemType, object subject);
    }
}